/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package assignment1;

import java.io.*;
import java.util.Vector;
/**
 *
 * @author cjaramillo
 */
public class Knowledgebase {
    Vector<Rule> m_rules;
    
    public void setup()
    {
        m_rules = new Vector<Rule>();
        this.setDefaultRules();
    }
    
    public Vector rules()
    {
        return m_rules;
    }
    
    public Rule getRuleToFire(Database database) throws IOException
    {
        Rule rule = new Rule();
        rule.setConsequentFromUserInput();
        return rule;
    }

    private void setDefaultRules() {
       
        Vector<String>rules = new Vector<String>();
        
        rules.add("If Rover orientation ! Target direction ~ Orient Rover Toward Target;If rover is not facing the target, face the target.");
        rules.add("If Rover AWARE_CLEAR_PATH = BOOL TRUE ~ Follow Path To Target;If the rover can find a clear path to the target, follow it.");
        rules.add("If Rover has_subgoals = BOOL FALSE ~ Create subgoal list;If the rover doesn't have a list of subgoals, make one.");
        rules.add("If Rover subgoals_contain_obstacles = BOOL TRUE ~ Remove obstacles from subgoals;If the rover's subgoals list contains obstacles, remove the obstacles.");
        rules.add("If Rover subgoals_contain_current_position = BOOL TRUE ~ Move position to reached subgoal list;If the rover's subgoals list contains current position, remove the subgoal.");
        rules.add("If Rover can_reach_subgoal = BOOL TRUE ~ Follow Path To Subgoal;If the rover can reach a subgoal, move there.");
        rules.add("If Rover can_add_subgoals = BOOL TRUE ~ Add subgoals;If the rover can add more subgoals, add them.");

        for(int i=0; i<rules.size(); i++)
        {
            Rule newRule = new Rule();
            newRule.populateFromString(rules.elementAt(i));
            m_rules.add(newRule);
        }
    }
}
